package com.fenghuajueli.module_home.room.homevideo

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.fenghuajueli.libbasecoreui.BaseApplication

@Database(entities = [HomeVideo::class], version = 1, exportSchema = false)
abstract class HomeVideoDateBase : RoomDatabase() {
    abstract fun dao(): HomeVideoDao

    companion object {

        private var instance: HomeVideoDateBase? = null
        private val dbName = "homevideo.db"

        fun getInstance(): HomeVideoDateBase {
            return instance ?: synchronized(this) {
                Room.databaseBuilder(
                    BaseApplication.getApplication(),
                    HomeVideoDateBase::class.java,
                    dbName
                )
                    .createFromAsset(dbName)
                    .allowMainThreadQueries()
                    .build().apply { instance = this }
            }
        }
    }

}